home *** CD-ROM | disk | FTP | other *** search
- Path: news.netgate.net!news
- From: Tamara Johnson <malihini@netgate.net>
- Newsgroups: comp.lang.c
- Subject: Question - C (beginner)
- Date: Sat, 24 Feb 1996 17:23:29 -0800
- Organization: NetGate Communications
- Message-ID: <312FBA11.3946@netgate.net>
- NNTP-Posting-Host: d45.netgate.net
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b6a (Win95; I)
-
- Problem: not correctly counting chars in
- each word, not correctly counting words
- with >0 && <7 chars and words with >6 chars.
-
- Suggestions greatly appreciated,
- Tamara
-
- [stuff deleted - snippet?]
- {
- int i, cc, nl, nw, nc,inword;
-
- inword=NO;
- cc=nl=nw=nc=0;
-
- for(i=0;i<n;i++)
- {
- nc++;
- cc++;
- if(test_string[i]=='\n')
- nl++;
- if(test_string[i]==' '||test_string[i]=='\n'
- ||test_string[i]=='\0'||test_string[i]=='\t')
- inword=NO;
- else if(inword==NO)
- {
- inword=YES;
- nw++;
- if((cc>0)&&(cc<7)) under++;
- if(cc>6) over++;
- cc=0;
- }
- }
- }
-
- /* -----output-------
-
- Enter test string: tickle something ugly
- Number of words in the string: 3
- Number of words with 7 or more char: 2
- Number of words with 6 or less char: 1
- */
- --
- /* malihini@netgate.net */
- /* a.k.a. johnson_tamara@tandem.com */
- /* I used to think I knew logic, */
- /* then I found C. */
-